/**
 * 设置为首页
 */
function setHome(obj,vrl){ 
	try{ 
		obj.style.behavior='url(#default#homepage)';
		obj.setHomePage(vrl); 
	} 
	catch(e){ 
		if(window.netscape) { 
		try { 
			netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
		} 
		catch (e) { 
			alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。"); 
		} 
		var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch); 
		prefs.setCharPref('browser.startup.homepage',vrl); 
		}	
	}
	
	return false;
}

/**
 * 加入收藏
 */
function addFavorite(url,title) 
{ 
        try 
        { 
                window.external.addfavorite(url,title); 
        } 
        catch (e) 
        { 
                try 
                { 
                        window.sidebar.addPanel(title, url, ""); 
                } 
                catch (e) 
                { 
                        alert("加入收藏失败，请使用ctrl+d进行添加"); 
                } 
        } 
}

var lock_doJzPub = 0;
function doJzPub(obj, url)
{
	if (lock_doJzPub == 1)
		return false;
	
	lock_doJzPub = 1;
	
	var data = {};
	$("input").each(function (i, n){
		data[n.name] = n.value;
	});
	$.post(url, data,function (data){
		if (data.status != 1){
			alert(data.message);
		}else{
			alert(data.message);
			$("input").each(function (i, n){
				n.value = '';
				if (n.name == 'url')
					n.value = 'http://';
			});
		}
		lock_doJzPub = 0;
	}, 'json');
	
	return false;
}

var lock_doAPub = 0;
function doAPub(obj, url)
{
	if (lock_doAPub == 1)
		return false;
	
	lock_doAPub = 1;
	
	var data = {};
	$("input").each(function (i, n){
		data[n.name] = n.value;
	});
	$("select").each(function (i, n){
		data[n.name] = $(this).val();
	});
	
	$.post(url, data,function (data){
		if (data.status != 1){
			alert(data.message);
		}else{
			alert(data.message);
			$("input").each(function (i, n){
				n.value = '';
				if (n.name == 'url')
					n.value = 'http://';
			});
		}
		lock_doAPub = 0;
	}, 'json');
	
	return false;
}

/**
 * 异步统计
 */
function surl(url)
{
	$.get(url);

	return true;
}

/**
 * 支持家族
 */
function jz(id)
{
	$.post(jzUrl, {id:id}, function (data){
		if (data.status == 1){
			var p = parseInt($('#jzh_' + id).text());
			$('#jzh_' + id).text(++p);
		}
		alert(data.message);
	}, "json");
	
	return false;
}